package spring.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import spring.web.dao.BoardDao;
import spring.web.dto.BoardDto;


public class BoardViewController implements Controller {
	
	private BoardDao boardDao;
	
	public void setBoardDao(BoardDao boardDao) {
		this.boardDao = boardDao;
	}

	@Override
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		int seq = ServletRequestUtils.getIntParameter(request, "seq");
		
		BoardDto boardDto = boardDao.getView(seq);
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("boardView");
		mav.addObject("boardDto" , boardDto);
		return mav;
		
	}
	
	

}
